//
//  MPTaskInfoView.m
//  MarkPlatform
//
//  Created by xiao6 on 2017/12/29.
//  Copyright © 2017年 AT. All rights reserved.
//

#import "MPTaskInfoView.h"

@interface MPTaskInfoView()
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *detailLabel;
@property (weak, nonatomic) IBOutlet UILabel *deakLineLabel;
@property (nonatomic, weak) IBOutlet UIImageView *timeIcon;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *deadLineBottomCons;
@end

@implementation MPTaskInfoView

- (IBAction)clickUpAndDown:(id)sender {
    CGFloat constant = 0;
    if (self.detailLabel.hidden == YES) {
        self.detailLabel.hidden = NO;
        self.deakLineLabel.hidden = NO;
        self.timeIcon.hidden = NO;
        constant = 10;
    }
    else {
        self.detailLabel.hidden = YES;
        self.deakLineLabel.hidden = YES;
        self.timeIcon.hidden = YES;
        constant = - (self.height - 20 - 10 - 58);
    }
    self.deadLineBottomCons.constant = constant;
}
- (void)setModel:(MPTaskModel *)model {
    if (!model) {
        return;
    }
    _model = model;
    self.titleLabel.text = _model.title;
    self.detailLabel.text = model.step;
    self.priceLabel.text = [NSString stringWithFormat:@"¥ %.2f", _model.price];
    CGFloat remainDay = (_model.endTime / 1000.f - [[NSDate date] timeIntervalSince1970]) / 60.f / 60.f / 24.f ;
    if (remainDay >= 0) {
        self.deakLineLabel.text = [NSString stringWithFormat:@"%.0f天后截止",remainDay];
    }
}

@end
